<template>
  {{ x.y }}
  <button @click="x.y++">点我++</button>
  <button @click="x = { y: 888 }">点我替换x.y</button>
  <hr />
  <h4>{{ person }}</h4>
  <h1>姓名：{{ name }}</h1>
  <h1>年龄：{{ age }}</h1>
  <h1>薪资：{{ job.j1.salary }}w</h1>
  <button @click="name += '~'">增加波浪线</button>
  <button @click="age++">增长年龄</button>
  <button @click="job.j1.salary++">加薪</button>
</template>

<script>
import { reactive, toRefs, shallowReactive, shallowRef } from "vue";

export default {
  name: "Demo",
  setup() {
    const person = shallowReactive({
      name: "李文泰",
      age: 20,
      job: {
        j1: {
          salary: "20",
        },
      },
    });

    const x = shallowRef({
      y: 0,
    });

    //返回对象
    return { x, person, ...toRefs(person) };
  },
};
</script>

<style>
</style>
